The present invention relates in general to analysis of thread latency. More particularly, the present invention relates to a method, apparatus, and a non-transitory computer readable medium including code that evaluates thread latency caused by preemption of threads and power management policy of hardware regarding the threads.
In computer programming, a thread is a minimum unit of execution of central process unit (CPU) utilization. Programs can be partitioned into multiple threads. Each thread can be executed independently from other threads of a same program. On a multi-processor or multi-core processor machine, several threads of a program can be executed at the same time. Hence, the thread model is a flexible organization mechanism that increases program execution efficiency due to parallel execution of program codes.
As the threads require to access to limited resources on a machine (e.g. CPU, memory, and other hardware), each thread needs to be scheduled by an operating system or kernel of the machine. When a thread is woken up, the thread will be then placed into a run queue. The threads placed into the run queue will wait for access to the resources based on their respective priorities given by the operating system.
However, due to various factors, the threads may be unintentionally starved for access to a particular resource. Thus, the threads may stay in the run queue for a long time, while only gets access to the resources for a relatively short time. This is thread latency, which may cause a bottleneck of performance of the machine because modern computer usually has pipeline architecture. The latency of one thread may disadvantageously affect the execution of another thread. In view of this, there is a need to analyze what factors cause the thread latency in order for better system performance.